VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsPacketBuffer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private buffer As String
Private Declare Sub RtlMoveMemory Lib "kernel32" (Destination As Any, Source As Any, ByVal Length As Long)


Public Function InsertBYTE(Data As Integer)
    buffer = buffer & Chr(Data)
End Function

Public Function InsertString(Data As String)
    buffer = buffer & Data & Chr(0)
End Function

Public Function InsertNonNTString(Data As String)
    buffer = buffer & Data
End Function

Public Function MakeWORD(value As Integer) As String
Dim strReturn As String * 2
    RtlMoveMemory ByVal strReturn, value, 2
    MakeWORD = strReturn
End Function

Public Function SendProxyPacket(Winsock As Winsock)
    If Winsock.State <> sckConnected Then: Exit Function
       buffer = buffer
       Winsock.SendData buffer
       buffer = ""
End Function

Public Function SendPacket(Winsock As Winsock, PacketID As Byte)
    If Winsock.State <> sckConnected Then: Exit Function
       Winsock.SendData Chr(&HFF) & Chr(PacketID) & MakeWORD(Len(buffer) + 4) & buffer
       buffer = ""
End Function



